package com.example.wechattakeaway.controller;

import com.example.wechattakeaway.accessctro.RolePermission;
import com.example.wechattakeaway.form.mernoticeform.InsertMerNoticeForm;
import com.example.wechattakeaway.form.mernoticeform.UpdateMerNoticeForm;
import com.example.wechattakeaway.service.MerNoticeService;
import com.example.wechattakeaway.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/MerNoticeController")
@Api(tags = "商家公告管理模块")
public class MerNoticeController {
    @Autowired
    MerNoticeService merNoticeService;

    @ApiOperation(value = "添加商家公告信息",notes = "商家web端")
    @PostMapping("/insertMerNotice")
    public ResultVO insertMerNotice(InsertMerNoticeForm insertMerNoticeForm){

        return merNoticeService.insertMerNotice(insertMerNoticeForm);
    }

    @ApiOperation(value = "编辑商家公告信息",notes = "商家web端")
    @PostMapping("/updateNotice")
    public ResultVO updateNotice(UpdateMerNoticeForm updateMerNoticeForm){

        return merNoticeService.updateNotice(updateMerNoticeForm);
    }

    @ApiOperation(value = "根据商家id查询所有公告信息列表（分页）",notes = "商家web端")
    @ApiImplicitParam(name="merchantId",value="商家id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectAllNoticeByMerId")
    public ResultVO selectAllNoticeByMerId(@RequestParam("pageNum") Integer pageNum,@RequestParam("merchantId") Integer merchantId){
        return merNoticeService.selectAllNoticeByMerId(pageNum,merchantId);
    }

    @ApiOperation(value = "根据商家公告id查询对应商家公告",notes = "小程序端以及商家web端")
    @ApiImplicitParam(name="noticeId",value="公告id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectNoticeById")
    public ResultVO selectNoticeById(@RequestParam("noticeId") Integer noticeId){
        return merNoticeService.selectNoticeById(noticeId);
    }

    @ApiOperation(value = "根据商家id以及公告显示状态为显示来查询对应商家允许显示公告",notes = "小程序端")
    @ApiImplicitParam(name="merchantId",value="商家id",example = "1",dataType = "Integer",paramType = "query")
    @GetMapping("/selectNoticeByMerchantId")
    public ResultVO selectNoticeByMerchantId(@RequestParam("merchantId") Integer merchantId){
        return merNoticeService.selectNoticeByMerchantId(merchantId);
    }

    @ApiOperation(value = "根据商家公告id删除商家公告",notes = "商家web端")
    @PostMapping("/deleteMerNotice")
    public ResultVO deleteMerNotice(Integer noticeId){

        return merNoticeService.deleteMerNotice(noticeId);
    }
}
